﻿using System.Collections;
using System.Collections.Generic;

namespace AE_Installs
{
    class AEX
    {
        public string Name { get; set; }

        public string Regname { set; get; }

        public ArrayList Children;

        public string[] ChildrenDirectorys { set; get; }

        public Dictionary<string, string[]> AexDic = new Dictionary<string, string[]>();

        public string EN { set; get; }

        public string CH { set; get; }
        /// <summary>
        /// 相关文件的绝对路径|文件的保存路径
        /// </summary>
        public string[] RelateFiles { set; get;}

        public Dictionary<string, string> RegisterDic = new Dictionary<string, string>();

        public AEX()
        { }

        public void SetChildren(string[] children)
        {
            this.ChildrenDirectorys = children;
        }

        public void SetRelateFiles(string[] relatefiles)
        {
            this.RelateFiles = relatefiles;
        }

        public void ResolveRegister(string srcString,ref string regname)
        {
            string temp = srcString;
            string[] temps = temp.Split('\n');
            bool flag = false;

            List<string[]> stringArrList = new List<string[]>();
            foreach(string s in temps)
            {
                s.TrimStart(new char[] { '\r',' ','\n'});
                s.TrimEnd(new char[] { '\r', ' ', '\n' });
                string[] str = s.Split('=');
                if (str.Length > 1)
                {
                    
                    if(str[1].StartsWith("\"C:"))
                    {
                        stringArrList.Add(str);
                    }
                }

                System.Console.WriteLine(s.EndsWith("]\r"));
                if(s.StartsWith("[") && s.EndsWith("]\r"))
                {
                    string[] ss = s.Split(new char[] { '\\' });
                    if (ss.Length<=3)
                        if (!flag)
                        {
                            flag = true;
                            regname = ss[ss.Length - 1];
                            regname = regname.TrimEnd(new char[] { '\r',']',' ','\n'});
                            //regname = regname.Remove(regname.Length - 1);
                            //this.Regname = regname;
                        }
                }
            }

            foreach(string[] arr in stringArrList)
            {
                System.Console.WriteLine(arr[0] + "发送给" + arr[1]);
                RegisterDic.Add(arr[0], arr[1].TrimEnd(new char[] { '\r',' ','\n'}));
            }
        }


    }
}
